<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="crm.control.ProductControl" %>
<%@ page import="crm.model.Product_model" %>
<%@ page import="crm.util.ParamUtil"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Calendar" %>
<%@page import="crm.model.Product_system"%>
<%@page import="crm.model.Product_service"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>My JSP 'product_service_add_do.jsp' starting page</title>
  </head>
  
  <body>
    <% 
       request.setCharacterEncoding("UTF-8"); 
       Product_service productService=new Product_service();
     
       String service_name=ParamUtil.getString(request,"product_service_name");
       productService.setService_name(service_name);
       
       String service_number=ParamUtil.getString(request,"product_service_number");
       productService.setService_number(service_number);
       
       String service_price=ParamUtil.getString(request,"product_service_price","");
       productService.setPrice(service_price);
       
       String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
       String create_time=ParamUtil.getString(request,"product_service_create_time",date);
       productService.setCreate_time(create_time);
       
       String description=ParamUtil.getString(request,"product_service_description","无");
       productService.setDescription(description);
         
       if(productService.getService_number()==null){ 
            %>
            <script type="text/javascript">
            window.alert("服务编号不能为空");
            window.location.href="product_service_add.jsp";
            </script>
            <%}else if(ProductControl.serviceNameIsExist(service_name)){
            %>
            <script type="text/javascript">
            window.alert("服务名称重复！添加失败");
            window.location.href="product_service_add.jsp";
            </script>   
            <%}else if(ProductControl.serviceNumberIsExist(service_number)){
            %>
            <script type="text/javascript">
            window.alert("服务编号重复！添加失败");
            window.location.href="product_service_add.jsp";
            </script>
            <%}else if(ProductControl.addProductService(productService)){
            %>
           <script type="text/javascript">
if (window.confirm("添加商品成功，是否继续添加？"))
	window.location.href = "product_service_add.jsp";
else
	window.location.href = "product_service.jsp";
           </script>
           <%
           }
           %>
  </body>
</html>
